#ifndef JKPROCESSMONITOR_H
#define JKPROCESSMONITOR_H

#include <QProcess>
#include <QMutex>
#include <QHttpServer/qhttpserver.h>
#include <QHttpServer/qhttprequest.h>
#include <QHttpServer/qhttpresponse.h>

class JKProcessMonitor : public QObject
{
    Q_OBJECT
public:
    explicit JKProcessMonitor(QObject *parent = nullptr);
    virtual ~JKProcessMonitor();
    bool execute(const QString &program, const QStringList &arguments, QByteArray &result, QProcess::ProcessChannelMode channelMode=QProcess::MergedChannels);
    void start();
    void stop();

private:
    enum TIMER_STATE{START=1, STOP=2};
    int mTimerState{STOP};  // Timer状态
    bool mNeedStop{false};
    QMutex mMutex;

    QHttpServer mServer;

signals:
    void publish(QString topic);

private slots:
    void setTimer(int msec);
    void timeout();
    void procRequest(QHttpRequest *request, QHttpResponse *response);
};

#endif // JKPROCESSMONITOR_H
